import {App} from 'vue';
import {createRouter, createWebHistory} from 'vue-router';
import {MainLayout} from '@/layouts/index';
import {setupRouterGuard} from './guard/index';
import {exampleModuleRoutes} from './modules/example';
import {demoModuleRoutes} from './modules/demo';

// import {demo_1ModuleRoutes} from './modules/demo1';
import HomeView from '@/views/HomeView.vue';
import AboutView from '@/views/AboutView.vue';

const routes = [
  {
    path: '/',
    name: 'home',
    component: MainLayout,
    hidden: false,
    meta: {
      title: '首页',
      icon: 'home',
      isHas: false,
      link: null,
    },
    children: [
      {
        path: '/',
        name: 'home',
        component: HomeView,
        meta: {
          title: '',
          isHas: false,
          link: null,
        },
      },
      {
        path: '/about',
        name: 'about',
        component: AboutView,
        meta: {
          title: '',
          isHas: false,
          link: null,
        },
      },
    ],
  },
  exampleModuleRoutes,
  demoModuleRoutes,
];
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
});
// 配置路由器
export function setupRouter(app: App<Element>) {
  app.use(router);
  setupRouterGuard(router);
}
export default router;
